﻿using System.Threading.Tasks;
using Magicodes.ExporterAndImporter.Excel.AspNetCore;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using NP.BPMReportPlatform.ExternalProcessingRecord.Dto;
using Volo.Abp.Application.Dtos;

namespace NP.BPMReportPlatform.ExternalProcessingRecord
{
    /// <summary>
    /// 外加工记录表
    /// </summary>
    [Authorize]
    [ApiController]
    [Route("api/ExternalProcessingRecord")]
    public class ExternalProcessingRecordController : BPMReportPlatformController
    {
        /// <summary>
        /// 外加工记录表 Service
        /// </summary>
        private readonly IExternalProcessingRecordService _externalProcessingRecordService;

        public ExternalProcessingRecordController(IExternalProcessingRecordService externalProcessingRecordService)
        {
            _externalProcessingRecordService = externalProcessingRecordService;
        }

        /// <summary>
        /// 外加工记录表 查询数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("ExternalProcessingRecord/GetAllAsync")]
        public async Task<PagedResultDto<GetExternalProcessingRecordOutput>> GetAllAsync(
            [FromBody] GetExternalProcessingRecordInput input)
        {
            return await _externalProcessingRecordService.GetAllAsync(input);
        }

        /// <summary>
        /// 秀珀工程项目审批流程 导出数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("ExternalProcessingRecord/ExportAsync")]
        public async Task<XlsxFileResult<GetExternalProcessingRecordOutput>> ExportAsync(
            [FromBody] GetExternalProcessingRecordInput input)
        {
            var rst = await _externalProcessingRecordService.ExportAsync(input);
            return new XlsxFileResult<GetExternalProcessingRecordOutput>(rst, "导出Excel");
        }
    }
}